/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Nuvoton Technoledge Corp. 
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//  Date   : Apr/21/2015
//***********************************************************************************************************

//***********************************************************************************************************
//  File Function: N76E003 Timer3 demo code
//***********************************************************************************************************

#include <stdio.h>
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_Define.h"

#define RELOAD_VALUE_H  (65536-50)/256
#define RELOAD_VALUE_L  (65536-50)%256

/************************************************************************************************************
*    TIMER 2 interrupt subroutine
************************************************************************************************************/
void Timer3_ISR (void) interrupt 16 
{
    clr_TF3;
    P02 = ~P02;                                 //P0.2 toggle when TF3 interrupt
}

/************************************************************************************************************
*    Main function 16 bit auto reload Timer 3
************************************************************************************************************/
void main (void)
{
    Set_All_GPIO_Quasi_Mode;
  
    RH3 = RELOAD_VALUE_H;                       //initial counter values 
    RL3 = RELOAD_VALUE_L;    
    
    set_ET3;                                    //enable Timer3 interrupt
    set_EA;                                     //enable interrupts
    set_TR3;                                    //Timer3 run

    while(1);
}

